package com.demo.caizi.biz;

import com.demo.caizi.biz.domain.CustomInfo;
import com.demo.caizi.config.context.CustomContext;
import com.demo.caizi.config.context.CustomContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;

@RestController
public class BizController {

    @Autowired
    BizService bizService;

    @Autowired
    PodamFactory podamFactory;

    @GetMapping("trading")
    public void trade(){
        CustomContext context = new CustomContext();
        CustomInfo customInfo = podamFactory.manufacturePojo(CustomInfo.class);
        context.setCustomInfo(customInfo);
        CustomContextHolder.setHolder(context);
        bizService.trading();
    }

    @GetMapping("custom/{id}")
    public CustomInfo getCustom(@PathVariable String id){
        CustomInfo customInfo = podamFactory.manufacturePojo(CustomInfo.class);
        customInfo.setCustomNo(id);
        return customInfo;
    }
}
